import { defineStore } from 'pinia';

export const useUserStore = defineStore('user', {
  state() {
    return {
      userName: "",
      userID: "",
    }
  },
  actions: {
    setUser(uname, id) { // 设置用户信息
      this.userID = id;
      this.userName = uname;
    },
    exitLogin() { // 退出登录
      this.userID = "";
      this.userName = "";
    }
  },
  getters: {
    loginStatus(state) { // 判断用户是否登录
      if(state.userName && state.userID)
        return true;
      else
        return false;
    }
  }
});